home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-03-19 | 39.1 KB | 1,998 lines |
- * $Id: graphics.s 1.1 1999/02/03 04:10:07 jotd Exp jotd $
- **************************************************************************
- * GRAPHICS LIBRARY
- **************************************************************************
-
- CMOVE:MACRO
- move.l \1,A1
- move.w \2,D0
- move.w \3,D1
- bsr _CMove
- bsr _CBump
- ENDM
-
- CEND:MACRO
- move.l \1,A1
- move.w #10000,D0
- move.w #255,D1
- bsr _CWait
- bsr _CBump
- ENDM
-
- **************************************************************************
- * INITIALIZATION
- **************************************************************************
-
- GFXINIT move.l _gfxbase,d0
- beq .init
- rts
-
- .init move.l #1056,d0 ;-_LVOWriteChunkyPixels,d0
- move.l #$2A8,d1
- lea _gfxname,a0
- bsr _InitLibrary
- move.l d0,a0
- move.l d0,_gfxbase
-
- patch _LVOOwnBlitter(a0),MYRTS
- patch _LVODisownBlitter(a0),MYRTS
- patch _LVOInitView(a0),_InitView
- patch _LVOInitVPort(a0),_InitVPort
- patch _LVOFreeVPortCopLists(a0),_FreeVPortCopLists
- patch _LVOInitBitMap(a0),_InitBitMap
- patch _LVOInitRastPort(a0),_InitRastPort
- patch _LVOMakeVPort(a0),_MakeVPort
- patch _LVOMrgCop(a0),_MrgCop
- patch _LVOCWait(a0),_CWait ; added by JOTD
- patch _LVOCMove(a0),_CMove ; added by JOTD
- patch _LVOCBump(a0),_CBump ; added by JOTD
- patch _LVOTextLength(a0),_TextLength ; added by JOTD, lame
- patch _LVOLoadView(a0),_LoadView
- patch _LVOLoadRGB4(a0),_LoadRGB4
- ;; patch _LVOLoadRGB32(a0),_LoadRGB32
- patch _LVOSetRGB4(a0),_SetRGB4
- patch _LVOGetRGB4(a0),_GetRGB4
- patch _LVOFreeSprite(a0),_FreeSprite
- patch _LVOGetSprite(a0),_GetSprite
- patch _LVOChangeSprite(a0),_ChangeSprite
- patch _LVOMoveSprite(a0),_MoveSprite
- patch _LVOWaitBlit(a0),_WaitBlit
- patch _LVOBltBitMap(a0),_BltBitMap
- patch _LVOClipBlit(a0),_ClipBlit ; not accurate!
- patch _LVOVBeamPos(a0),_VBeamPos
- patch _LVODraw(a0),_Draw
- patch _LVOAllocBitMap(a0),_AllocBitMap ; V39, Ripped by JOTD
- patch _LVOMove(a0),_Move
- patch _LVOSetAPen(a0),_SetAPen
- patch _LVOSetBPen(a0),_SetBPen
- patch _LVOSetDrMd(a0),_SETDRAWMODE
- patch _LVOWaitTOF(a0),_WaitTOF
- patch _LVOWaitBOVP(a0),_WaitBOVP ; -- added by JOTD
- patch _LVORectFill(a0),_RectFill ; -- added by JOTD
- patch _LVOSetRast(a0),_SetRast ; -- added by JOTD
- patch _LVOInitTmpRas(a0),_InitTmpRas ; -- added by JOTD
- patch _LVOInitArea(a0),_InitArea ; -- added by JOTD
- patch _LVOReadPixel(a0),_ReadPixel
- patch _LVOWritePixel(a0),_WritePixel
- patch _LVOBltTemplate(a0),_BltTemplate
- patch _LVOAllocRaster(A0),_ALLOCRASTER
- patch _LVOFreeRaster(A0),_FREERASTER
- patch _LVOFreeCprList(A0),_FreeCprList ; JOTD, burntime
- patch _LVOBltClear(A0),_BltClear
- patch _LVOGetColorMap(A0),_GETCOLORMAP
- patch _LVOFreeColorMap(A0),_FREECOLORMAP
- patch _LVOUCopperListInit(a0),_UCopperListInit ; -- added by JOTD
- patch _LVOBestModeIDA(A0),MYRTZ ; -- added by JOTD
- patch _LVOBltMaskBitMapRastPort(A0),_BLTMASKBITMAPRASTPORT ; Harry
- patch _LVOOpenFont(A0),_OPENFONT
- patch _LVOSetFont(A0),_SETFONT
- patch _LVOText(A0),_PRINTTEXT
- patch _LVOGetDisplayInfoData(A0),MYRTZ ; JOTD, DGeneration
- MOVE.L #MYVIEW,gb_ActiView(A0)
- lea STDCOPPER(PC),a1
- MOVE.L a1,(gb_LOFlist,A0)
- MOVE.L a1,(gb_SHFlist,A0)
- MOVE.L a1,(_custom+cop2lc)
-
- move.l a1,OSM_COPLIST2 ; added by JOTD
-
- lea CPJMP2,a1
- move.l a1,(gb_copinit,a0)
-
- MOVE.L a1,(_custom+cop1lc)
- move.l a1,OSM_COPLIST1 ; added by JOTD
- lea.l _TOPAZ8FONT(PC),a1 ; added by Harry
- move.l a1,(gb_DefaultFont,a0) ; added by Harry
-
- moveq #4,d0 ;pal
- cmp.l #PAL_MONITOR_ID,_monitor
- beq.b .1
- moveq #1,d0 ;ntsc
- .1 MOVE.W d0,(gb_DisplayFlags,A0)
-
- clr.b (gb_SpriteReserved,a0)
- move.b #3,($ED,A0) ;jeff, crb_reserved, ripped!
-
- move.l A1,-(A7)
- lea .gfx1A8_table(pc),A1
- move.l (A1)+,($1A8,A0)
- move.l (A1)+,($1AC,A0)
- move.l (A1)+,($1B0,A0)
- move.l (A1)+,($1B4,A0)
- move.l (A1)+,($1B8,A0)
-
- move.l (A7)+,A1
-
- move.l A6,-(A7)
- move.l $4.W,A6
- move.l A0,($9C,A6) ; Jeff: change intvec data to GfxBase (Banshee...)
- move.l (A7)+,A6
-
- move.l $4.W,(gb_ExecBase,A0) ; sets ExecBase to gb_ExecBase offset
-
- move.l #_TOPAZ8FONT,(gb_DefaultFont,A0) ; bugfix, A0 missing!
-
- ; sprites initialization (JOTD)
- move.l A6,-(A7)
- move.l A0,A6 ; sets GfxBase
- bsr init_sprites
- move.l (A7)+,A6
-
- move.l A1,-(A7)
- lea _MonitorSpec(pc),A1
- move.l A1,(gb_current_monitor,A0)
- move.l (A7)+,A1
-
- clr.l -(a7) ;TAG_DONE
- pea RESTORECOPPER2(pc)
- move.l #WHDLTAG_CBSWITCH_SET,-(a7)
- move.l a7,a0
- move.l _RESLOAD(pc),a1
- jsr (resload_Control,a1)
- lea (12,a7),a7 ;restore sp
-
- tst.w (_custom+copjmp1)
- move.w #DMAF_SETCLR!DMAF_MASTER!DMAF_COPPER!DMAF_BLITTER,(_custom+dmacon)
-
- rts
-
-
- ; ??? used for AllocBitMap
- .gfx1A8_table:
- dc.l abm_table
- dc.l abm_table+120
- dc.l abm_table+144
- dc.l abm_table+168
- dc.l abm_table+192
-
- ; initialize sprites to avoid graphics glitches because of
- ; wild sprite pointers
-
- init_sprites:
- movem.l D0-D2/A0-A1,-(A7)
- moveq.l #7,D2 ; 8 sprites to set
-
- lea .cursor_sprite_data(pc),A2
- .loop:
- lea .cursor_sprite_struct(pc),A1
- move.w D2,.sprnum
- sub.l A0,A0 ; no view port!
- JSRLIB ChangeSprite
- dbf D2,.loop
- movem.l (A7)+,D0-D2/A0-A1
- rts
-
- .cursor_sprite_data:
- dc.W 0,0
- dc.w $AAAA,$5555
- dc.W 0,0
- .cursor_sprite_struct:
- dc.l 0
- dc.w 1 ; height=1
- dc.w 0,0 ; X,Y
- .sprnum
- dc.w 0 ; sprite number
-
- _MonitorSpec
- blk.b $28,$EE
- dc.w $20
- blk.b $9C-$2A,$EE
-
- RESTORECOPPER2 move.l a1,-(A7)
- move.l _gfxbase,a1
- move.l (gb_LOFlist,a1),a1
- move.l a1,(_custom+cop2lc)
- move.l a1,OSM_COPLIST2
- move.l (A7)+,a1
- jmp (A0)
-
- CNOP 0,4
- CPJMP2
- dc.l $0201fffe ;wait 0,2
- DC.L $008A0000 ;copjmp2
- STDCOPPER
- DC.L $FFFFFFFE
-
- MYVIEW
- DC.L _INITVIEWPORT
- DC.L STDCOPPER
- DC.L STDCOPPER
- DC.W 0
- DC.W 0
- DC.W 0
-
- _INITVIEWPORT
- DC.L $EEEEEEEE
- DC.L $EEEEEEEE
- DC.L $EEEEEEEE
- DC.L $EEEEEEEE
- DC.L $EEEEEEEE
- DC.L 0 ; UCopIns
- DC.W 0
- DC.W 0
- DC.W 0
- DC.W 0
- DC.W 0
- DC.B 0,0
- DC.L _INITRASINFO
-
- _INITLAYER:
- dc.l _INITLAYER,_INITLAYER
- dc.l 0
- dc.l $BBBBEEEE ; rastport
- ds.b 160-16
-
- _INITRASINFO
- DC.L 0
- DC.L $EEEEEEEE
- DC.W 0
- DC.W 0
-
- _FONTTABLE
- DC.L _TOPAZNAME,_TOPAZ8FONT
- DC.L 0
-
- _TOPAZNAME
- DC.B 'topaz.font',0
- EVEN
-
- _TOPAZ8FONT
- DC.L 0,0,0,0,0 ;EMPTY MESSAGEPORT
- DC.W 8 ;YSIZE
- DC.B 0 ;NO SPECIAL STYLE
- DC.B $41 ;FONTFLAGS:DESIGNED,ROMFONT
- DC.W 8 ;XSIZE
- DC.W 6 ;BASELINE
- DC.W 1 ;FETT: 1 PIXEL VERSETZT
- DC.W 1 ;1 TASK BENUTZT FONT (DUMMY)
- DC.B $20 ;LOWEST CHAR IS SPACE
- DC.B $FF ;HIGHEST CHAR IS "y
- DC.L _TOPAZ8DATA ;FONTIMAGES
- DC.W $C0 ;MODULO
- DC.L _TOPAZ8OFFSETS ;OFFSETTABLES
- DC.L 0 ;NON PROPORTIONAL FONT
- DC.L 0 ;NO KERNING
-
- _TOPAZ8DATA
- INCBIN REPLFONT_DATA
-
- _TOPAZ8OFFSETS
- INCBIN REPLFONT_BITS
-
- **************************************************************************
- * GRAPHICS LIBRARY FUNCTIONS
- **************************************************************************
-
- _UCopperListInit:
- cmp.l #0,a0
- bne.b .nz
- moveq.l #0,D0
- bra.b .exit ; error, returns NULL
- .nz
-
- movem.l D1-A6,-(A7)
-
- clr.l (A0) ; next list
-
- move.l A0,A2
- move.l D0,D2 ; number of copper instructions needed
-
- move.l #$22,D0 ; size of coplist struct
- move.l #MEMF_CLEAR,D1
- move.l (gb_ExecBase,A6),A6 ; gfxbase
- JSRLIB AllocMem
- move.l D0,(ucl_FirstCopList,A2)
- beq.b .alloc_fail
-
- move.l D0,(ucl_CopList,A2) ; coplist pointer stored in UCopList struct
-
- move.l D0,A3 ; coplist pointer
-
- ; init some fields
-
- clr.l (A3)
- move.l #$BEBEBEBE,(cl__CopList,A3)
- clr.l (cl__ViewPort,A3)
- clr.l (cl_CopLStart,A3)
- move.l #$BEBEBEBE,(cl_CopSStart,A3)
- clr.w (cl_Count,A3)
- move.w D2,(cl_MaxCount,A3)
-
- move.l D2,D0 ; # of instructions
- mulu #6,D0 ; size of coplist struct
- move.l #MEMF_CLEAR,D1
- JSRLIB AllocMem
- move.l D0,(cl_CopIns,A3) ; save list of copper instructions
- move.l D0,(cl_CopPtr,A3) ; pointer on current copper instruction
- beq.b .alloc_fail
-
-
- movem.l (A7)+,D1-A6
- move.l (ucl_FirstCopList,A0),D0 ; return value
- .exit:
- rts
-
- .alloc_fail:
- GFXFAIL _LVOUCopperListInit
-
-
- ; does not affect registers!
-
- _CMove:
- movem.l A0/A2,-(A7)
- move.l (ucl_FirstCopList,A1),A0
- move.l (cl_CopPtr,A0),A2 ; gets current copper instruction
- move.w #0,(0,A2) ; MOVE instruction
- move.w D0,(2,A2)
- move.w D1,(4,A2)
- movem.l (A7)+,A0/A2
- rts
-
- ; < A1: UCopList
- ; < D0: horiz wait
- ; < D1: vert. wait
- ; does not affect registers!
-
- _CWait:
- movem.l A0/A2,-(A7)
- move.l (ucl_FirstCopList,A1),A0
- move.l (cl_CopPtr,A0),A2 ; gets current copper instruction
- move.w #1,(0,A2) ; WAIT instruction
- move.w D0,(2,A2)
- move.w D1,(4,A2)
- movem.l (A7)+,A0/A2
- rts
-
- ; < A1: UCopList
- ; A0 is preserved here for convenience reasons (MakeVPort) !!!
-
- _CBump:
- move.l A0,-(a7)
- move.l (ucl_FirstCopList,A1),A0
- addq.l #6,(cl_CopPtr,A0) ; next copper instruction
- addq.w #1,(cl_Count,A0)
- move.l (a7)+,A0
- rts
-
- ; < A0: viewport
-
- _FreeVPortCopLists:
- movem.l A2/A6,-(A7)
- move.l A0,A2
-
- ; JOTD: free copper list structure and contents
-
- move.l (vp_DspIns,a2),A0
- move.l (cl_CopIns,A0),A1 ; copper instructions
- move.l (cl_MaxCount,A0),D0
- mulu #6,D0 ; size of buffer
- move.l $4.W,A6
- JSRLIB FreeMem
-
- move.l (vp_DspIns,a2),A1
- move.l (cl_CopLStart,a1),D0
- beq.b .nomerged
- move.l D0,A1
- move.l $4.W,A6
- JSRLIB FreeVec
- .nomerged
- move.l (vp_DspIns,a2),A1
- cmp.l #0,A1
- beq.b .nodsp
- move.l #$22,D0
- JSRLIB FreeMem
-
- clr.l (vp_DspIns,a2)
- .nodsp:
-
- ; nothing allocated for the 2 of them below
-
- clr.l (vp_SprIns,a2)
- clr.l (vp_ClrIns,a2)
-
- move.l (vp_UCopIns,a2),D0
- beq.b .skip
- clr.l (vp_UCopIns,a2)
-
- ; JOTD, now that UCopListInit is made, got to free the struct
- ; first, free copper instructions
-
- move.l D0,A0
- move.l (ucl_FirstCopList,A0),A2
- move.l (cl_CopIns,A2),A1 ; copper instructions
- move.l (cl_MaxCount,A2),D0
- mulu #6,D0 ; size of buffer
- move.l $4.W,A6
- JSRLIB FreeMem
-
- ; frees copperlist structure
-
- move.l A2,A1
- move.l #$22,D0
- move.l $4.W,A6
- JSRLIB FreeMem
- .skip
-
- movem.l (a7)+,A2/A6
- rts
-
- _InitTmpRas:
- move.l A1,(A0)
- move.l D0,4(A0)
- move.l A0,D0
- rts
-
- _InitArea:
- MOVE.L A1,4(A0)
- MOVE.L A1,(A0)
- MOVE D0,18(A0)
- ASL.L #2,D0
- ADDA D0,A1
- MOVE.L A1,12(A0)
- MOVE.L A1,8(A0)
- CLR 16(A0)
- RTS
-
- _InitView
- movem.l D0/A1,-(A7)
- move.w #$8,D0
- .zero
- clr.w (A1)+
- dbf D0,.zero
- movem.l (A7)+,D0/A1
- rts
-
- _InitVPort
- movem.l D0/A0,-(A7)
- move.w #9,D0
- .zero
- clr.l (A0)+
- dbf D0,.zero
-
- movem.l (A7)+,D0/A0
- move.b #$24,(vp_SpritePriorities,A0)
- rts
-
- ; < A1: rastport (ignored)
- ; < A0: text pointer (ignored)
- ; < D0: string length
-
- _TextLength:
- ; * 8 should do the trick
- add.l D0,D0
- add.l D0,D0
- add.l D0,D0
- rts
-
- ; < A1: rastport structure
-
- _InitRastPort
- MOVE.L #_INITLAYER,(A1) ; JOTD: Maniac Mansion
- MOVE.L #0,rp_BitMap(A1)
-
- MOVE.L #$EEEEEEEE,rp_AreaPtrn(A1)
-
- MOVE.L #$EEEEEEEE,rp_TmpRas(A1)
- MOVE.L #$EEEEEEEE,rp_AreaInfo(A1)
- MOVE.L #0,rp_GelsInfo(A1)
- MOVE.L #$FF0000FF,rp_Mask(A1)
- MOVE.L #$01000000,rp_DrawMode(A1)
- CLR.L rp_Flags(A1)
- CLR.L rp_cp_x(A1)
- CLR.L rp_minterms(A1)
- CLR.L rp_minterms+4(A1)
- CLR.L rp_PenWidth(A1)
- MOVE.L #_TOPAZ8FONT,rp_Font(A1)
- CLR.W rp_AlgoStyle(A1)
- MOVE.L #$00080008,rp_TxHeight(A1)
- MOVE.L #$00060008,rp_TxBaseline(A1)
- CLR.L rp_RP_User(A1)
-
- ; added by JOTD (Test Drive II)
- MOVE.B #1,rp_FgPen(A1)
- MOVE.B #2,rp_BgPen(A1)
- RTS
-
- .area_ptrn:
- dc.w 0
-
- _SetAPen:
- MOVE.B D0,rp_FgPen(A1)
- RTS
-
- _SetBPen:
- MOVE.B D0,rp_BgPen(A1)
- RTS
-
- _SETDRAWMODE
- MOVE.B D0,rp_DrawMode(A1)
- RTS
-
- _Move:
- MOVE.W D0,rp_cp_x(A1)
- MOVE.W D1,rp_cp_y(A1)
- RTS
-
- _BltClear:
- AND.W #2,D1
- BNE.S .FAIL
- LSR.W #1,D0
- SUBQ.W #1,D0
- .1 CLR.W (A1)+
- DBF D0,.1
- RTS
-
- .FAIL pea _LVOBltClear
- pea _gfxname
- bra _emufail
-
- _ALLOCRASTER
- ADD.W #$F,D0
- LSR.W #3,D0
- AND.W #$FFFE,D0
- MULU D1,D0
- MOVEQ.L #MEMF_CHIP!MEMF_PUBLIC,D1
- bsr ForeignAllocMem
- RTS
-
- _FREERASTER
- ADD.W #$F,D0
- LSR.W #3,D0
- AND.W #$FFFE,D0
- MULU D1,D0
- MOVE.L A0,A1
- bsr ForeignFreeMem
- RTS
-
- ; < D0: entries #
- ; > D0: colormap pointer
-
- _GETCOLORMAP
- MOVE.L D0,-(A7)
- ADD.L D0,D0
- ADDQ.L #8,D0
- MOVE.L #MEMF_CLEAR,D1
- bsr ForeignAllocMem
- TST.L D0
- BEQ.S .FAIL
- MOVE.L D0,A0
- MOVE.L (A7)+,D1
- MOVE.W D1,cm_Count(A0)
- LEA.L 8(A0),A1
- MOVE.L A1,cm_ColorTable(A0)
- CMP.W #$20,D1
- BLS.S .1
- MOVEQ.L #$20,D1
- .1 LEA.L .COLORTAB(PC),A0
- .2 MOVE.W (A0)+,(A1)+
- SUBQ.W #1,D1
- BNE.S .2
-
- .FAIL RTS
-
- .COLORTAB
- DC.B $00,$00,$0F,$00,$00,$F0,$0F,$F0
- DC.B $00,$0F,$0F,$0F,$00,$FF,$0F,$FF
- DC.B $06,$20,$0E,$50,$09,$F1,$0E,$B0
- DC.B $05,$5F,$09,$2F,$00,$F8,$0C,$CC
- DC.B $00,$00,$01,$11,$02,$22,$03,$33
- DC.B $04,$44,$05,$55,$06,$66,$07,$77
- DC.B $08,$88,$09,$99,$0A,$AA,$0B,$BB
- DC.B $0C,$CC,$0D,$DD,$0E,$EE,$0F,$FF
-
- _FREECOLORMAP ;A0-*COLORMAP
- MOVE.L (A2),-(A7)
- MOVE.L A0,A2
- MOVE.L cm_ColorTable(A2),A1
- MOVEQ.L #0,D0
- MOVE.W cm_Count(A2),D0
- ADD.L D0,D0
- ADDQ.L #7,D0
- AND.L #$FFFFFFF8,D0
- BSR ForeignFreeMem
-
- MOVE.L A2,A1
- MOVEQ.L #8,D0
- BSR ForeignFreeMem
- MOVE.L (A7)+,A2
- RTS
-
- _OPENFONT
- move.l a2,-(a7)
- ; CMP.W #8,4(A0)
- ; BNE.S .ERR
- MOVE.L (A0),A1
-
- lea _FONTTABLE(PC),a2
- .next move.l (a2)+,a0
- move.l a0,d0
- beq .ERR
- bsr _strcmp
- beq .found
- addq.l #4,a2
- bra .next
-
- .found MOVE.L (A2),D0
- move.l (a7)+,a2
- rts
-
- .ERR pea _LVOOpenFont
- pea _gfxname
- bra _emufail
-
- _SETFONT MOVE.L A0,rp_Font(A1)
- CLR.W rp_AlgoStyle(A1)
- MOVE.W tf_YSize(A0),rp_TxHeight(A1)
- MOVE.W tf_XSize(A0),rp_TxWidth(A1)
- MOVE.W tf_Baseline(A0),rp_TxBaseline(A1)
- MOVE.W tf_XSize(A0),rp_TxSpacing(A1)
- RTS
-
-
- _PRINTTEXT ;A0-*STRING, A1-*RASTPORT, D0-CHARCOUNT
- MOVEM.L D2-D7/A2-A6,-(A7)
- MOVE.L A0,A2 ;keep stringpointer
- MOVE.L D0,D2
- MOVE.L rp_Font(A1),A3 ;get font
- MOVE.L tf_CharLoc(A3),A4 ;get chardescriptionpointer
- .NXPRINT MOVE.L D2,-(A7)
- MOVE.L tf_CharData(A3),A5 ;get chardatapointer
- MOVEQ.L #0,D3
- MOVE.B (A2)+,D3 ;get char
- CMP.B tf_HiChar(A3),D3
- BHI.S .SPACEPRINT
- CMP.B tf_LoChar(A3),D3
- BHS.S .OKPRINT
- .SPACEPRINT MOVE.B tf_LoChar(A3),D3
- .OKPRINT SUB.B tf_LoChar(A3),D3
- LSL.W #2,D3
- MOVE.W (A4,D3.W),D4 ;get charposition on font - bitoffset
- MOVE.W 2(A4,D3.W),D2 ;bitwidth of char
- MOVE.W D4,D3
- AND.W #$F,D4 ;bitshift
- AND.W #$FFF0,D3
- LSR.W #3,D3 ;byteoffset of char
- MOVE.W rp_cp_x(A1),D6 ;x-printposition
- MOVE.W D6,D5
- AND.W #$F,D6 ;x-bitshift
- AND.W #$FFF0,D5
- LSR.W #3,D5
- EXT.L D5
- MOVE.W rp_cp_y(A1),D7 ;y-printposition
- SUB.W tf_Baseline(A3),D7
- MOVE.L rp_BitMap(A1),A0
- MULU (A0),D7 ;memoryoffset of the line by * bytesperrow
- ADD.L D5,D7 ;memoffset of printposition w/o shift
-
- MOVEQ.L #0,D1 ;print char
- .NXLINE MOVE.L (A5,D3.W),D5 ;get charline from charsetdata
- LSL.L D4,D5
- MOVEQ.L #-1,D0 ;mask rest out
- LSR.L D2,D0
- NOT.L D0
- AND.L D0,D5 ;chardata in D5, beginning with bit 31
- LSR.L D6,D5
- LSR.L D6,D0 ;contain now a 'window' of set bits at printpos
- MOVEM.L D1/D3/D4/D6,-(A7)
- BTST #0,rp_AlgoStyle(A1)
- BEQ.S .NOUNDERLINE
- MOVE.W tf_YSize(A3),D3
- SUBQ.W #1,D3
- CMP.W D3,D1
- BNE.S .NOUNDERLINE
- MOVE.L D0,D5
- .NOUNDERLINE MOVE.L D0,D3
- NOT.L D3
- MOVEQ.L #0,D6
- .NXPLANE MOVE.L D6,D1
- LSL.L #2,D1
- MOVE.L bm_Planes(A0,D1.W),A6 ;planepointertable in a6
- MOVE.L (A6,D7.L),D1 ;screendata
- BTST #0,rp_DrawMode(A1) ;test if JAM2
- BNE.S .JAM2
- OR.L D5,D1
- BTST D6,rp_FgPen(A1)
- BNE.S .MOVETOPLANE
- EOR.L D5,D1
- BRA.S .MOVETOPLANE
- ;now check colors
- .JAM2 BTST D6,rp_BgPen(A1)
- BNE.S .BGSET
- AND.L D3,D1 ;clear bits
- BTST D6,rp_FgPen(A1)
- BEQ.S .KEEPFG1
- OR.L D5,D1 ;set bits
- .KEEPFG1 BRA.S .MOVETOPLANE
-
- .BGSET OR.L D0,D1
- BTST D6,rp_FgPen(A1)
- BNE.S .KEEPFG2
- EOR.L D5,D1
- .KEEPFG2
- .MOVETOPLANE MOVE.L D1,(A6,D7.L)
- ADDQ.L #1,D6
- CMP.B bm_Depth(A0),D6 ;for each bitplane
- BLO.S .NXPLANE
- MOVEM.L (A7)+,D1/D3/D4/D6
-
- ADD.W tf_Modulo(A3),A5
- MOVE.L D7,A6
- ADD.W bm_BytesPerRow(A0),A6
- MOVE.L A6,D7
- ADDQ.L #1,D1
- CMP.W tf_YSize(A3),D1 ;all lines
- BLO.W .NXLINE
- ADD.W D2,rp_cp_x(A1) ;rp_position moved
- MOVE.L (A7)+,D2
- SUBQ.L #1,D2 ;until string is exhausted
- BNE.W .NXPRINT
- MOVEM.L (A7)+,D2-D7/A2-A6
-
- moveq.l #0,D0 ; JFF: old expected return value
- RTS ; (Little Computer People)
-
- _InitBitMap ;a0=bm d0=depth d1=width d2=height
- addq.w #7,d1
- lsr.w #3,d1
- AND.W #$FFFE,D1 ;LORDS OF WAR
-
- move.w d1,(bm_BytesPerRow,a0)
- move.w d2,(bm_Rows,a0)
- clr.b (bm_Flags,a0)
- move.b d0,(bm_Depth,a0)
- clr.w (bm_Pad,a0)
-
- ; put trash in planes data
-
- moveq.l #7,D0
- move.l #$BBBBBBBB,D1
- lea (bm_Planes,A0),A0
- .loop
- move.l D1,(A0)+
- dbf D0,.loop
- rts
-
-
- _MakeVPort ;a0=view a1=viewport
- movem.l d2/a2-a4,-(a7)
-
- ; JOTD: store viewport in view structure
- move.l a1,(v_ViewPort,a0)
-
- move.l a0,a2
- move.l a1,a3
- lea (-$C,A7),A7 ; size of UCopList structure
- move.l A7,A0
- move.l #100,D0 ; room for 100 instructions, should be enough
- bsr _UCopperListInit
- tst.l d0
- trapeq
- BEQ.W .ERR
-
- move.l a2,a0 ; view
- move.l a3,a1 ; viewport
-
- move.l d0,a2 ;A2 = coplist
- move.l a2,(vp_DspIns,a1)
- move.l (vp_RasInfo,a1),a0
- move.l (ri_BitMap,a0),a0
-
- move.l a1,(cl__ViewPort,a2) ; store viewport
-
- ; build basic copperlist
-
- CMOVE A7,#diwstrt,#$2981
-
- move.w #$2981,d0
- move.w (bm_BytesPerRow,a0),d1
- lsl.w #3,d1 ;bytes -> pixel
- add.b d1,d0
- move.w (bm_Rows,a0),d1
- lsl.w #8,d1
- add.w d1,d0
- move.w d0,d1
- move.w #diwstop,D0
- bsr _CMove
- bsr _CBump
-
-
- CMOVE A7,#ddfstrt,#$0038
-
- CMOVE A7,#ddfstop,#$00D0
-
- CMOVE A7,#bplcon1,#0
- CMOVE A7,#bpl1mod,#0
- CMOVE A7,#bpl2mod,#0
-
- moveq #0,d0
- move.b (bm_Depth,a0),d0
- ror.w #4,d0
- or.w #$200,d0
- move.w d0,d1
- move.w #bplcon0,d0
- bsr _CMove
- bsr _CBump
-
-
- move.b (bm_Depth,a0),d2
- lea (bm_Planes,a0),a0
- move.w #bplpt,d0
- .lp
- move.w (A0)+,D1
- bsr _CMove
- bsr _CBump
- addq.l #2,D0
- move.w (A0)+,D1
- bsr _CMove
- bsr _CBump
- addq.l #2,D0
-
- subq.b #1,d2
- bne.b .lp
-
- CMOVE A7,#dmacon,#DMAF_SETCLR+DMAF_RASTER
- CEND A7
-
- lea ($C,A7),A7
- movem.l (a7)+,d2/a2-a4
- rts
-
- .ERR pea _LVOMakeVPort
- pea _gfxname
- bra _emufail
-
-
- _MrgCop ;a1=view
- movem.l D2/A2/A3/A6,-(A7)
- moveq.l #0,D2 ; # of copper instructions
-
- move.l (v_ViewPort,a1),a0 ; a0: viewport
- move.l (vp_UCopIns,a0),D0 ; gets user copper instructions
- beq.b .nouser
-
- move.l D0,A2
- move.l (ucl_FirstCopList,A2),A2 ; user copper list
-
- move.w (cl_Count,A2),D2 ; number of user instructions stored
- .nouser
- move.l (vp_SprIns,a0),D0 ; gets user copper instructions
- beq.b .nosprites
-
- move.l D0,A2
- add.w (cl_Count,A2),D2 ; adds number of sprite instructions
- .nosprites
- move.l (vp_DspIns,a0),a2
- move.l a0,(cl__ViewPort,A2) ; store viewport
- add.w (cl_Count,A2),D2 ; adds number of display instructions
-
- add.l D2,D2
- add.l D2,D2 ; D2 * 4
-
- move.l D2,D0
- movem.l A0/A1/A6,-(A7)
- move.l (gb_ExecBase,A6),A6
- move.l #MEMF_CHIP|MEMF_CLEAR,D1
- JSRLIB AllocVec
- movem.l (A7)+,A0/A1/A6
- move.l D0,(cl_CopLStart,A2) ; store total clist in DspList !!
- beq .fail
-
- ; now convert available copperlists to hardware info
-
- move.l D0,A3
-
- move.l (vp_DspIns,a0),D0
- bsr mrgcop_convert
-
- move.l (vp_UCopIns,a0),D0
- beq.b .nousermrg
- move.l D0,A2
- move.l (ucl_FirstCopList,A2),D0 ; user copper list
- bsr mrgcop_convert
- .nousermrg
- move.l (vp_SprIns,a0),D0
- beq.b .nosprmrg
- bsr mrgcop_convert
- .nosprmrg
-
- move.l #$FFFFFFFE,(A3)
-
- ; conversion done, set copperlist
-
- move.l (vp_DspIns,a0),a2
- move.l (cl_CopLStart,A2),(v_LOFCprList,a1)
-
- .exit
- movem.l (A7)+,D2/A2/A3/A6
- rts
-
- .fail:
- GFXFAIL _LVOMrgCop
-
- ; < D0: CopList structure
- ; <> A3: pointer on hardware buffer
-
- mrgcop_convert:
- tst.l D0
- beq.b .exit
-
- movem.l D0-D2/A0,-(A7)
- move.l D0,A0 ; coplist structure
- moveq.l #0,D0
- move.w (cl_Count,A0),D2 ; # of instructions
- move.l (cl_CopIns,A0),A0 ; start of list
-
- .loop
- move.w (2,A0),d0
- move.w (4,A0),d1
- tst.w (A0)
- beq.b .move
- .wait
- cmp.w #10000,D0
- beq.b .quit ; end of copperlist
- move.b d0,(A3)+
- move.b d1,(A3)+
- move.w #$FFFE,(A3)+
- bra .next
- .move
- move.w d0,(A3)+
- move.w d1,(A3)+
- .next
- addq.l #6,A0
- subq.l #1,D2
- bne.b .loop
- .quit
- movem.l (A7)+,D0-D2/A0
- .exit
- rts
-
- _LoadView ;a1=view
- move.l a1,d0
- beq .noview
- move.l (v_LOFCprList,a1),d0
- beq.b .fail
-
- move.l d0,(gb_LOFlist,a6)
- move.l d0,(_custom+cop2lc)
- move.l d0,OSM_COPLIST2
- rts
-
- .noview
- CLR.L (gb_ActiView,a6)
- MOVE.L #STDCOPPER,(gb_LOFlist,a6)
- move.l (v_SHFCprList,a1),(gb_SHFlist,a6)
- rts
-
- .fail
- GFXFAIL _LVOLoadView
-
- ; JOTD. untested, unplugged
- ;a0=viewport a1=colors table
- ifeq 1
- _LoadRGB32:
- cmp.l #0,A1
- beq.b .exit
- movem.l D2/D3/D5,-(A7)
- lea 12(A7),A7
-
- lea _custom,A0
-
- moveq.l #0,D5
- moveq.l #0,D3
- moveq #0,D2 ; bank number
-
- move.w (A1)+,D0 ; total # of colors to load
- move.w (A1)+,D1 ; first color number to load
- add.w D1,D1 ; D1*2
- subq.w #1,D0
- .loop
-
- move.l (A1)+,(A7) ; red
- beq.b .out
- move.l (A1)+,4(A7) ; green
- move.l (A1)+,8(A7) ; blue
-
- ; compute current bank number
- ; & sets the correct color bank
-
- move.w D1,D3
- and.w #$E000,D3
- bset #9,D3 ; higher colors
-
- ; compute current color
-
- move.w D1,D2
- and.w #$1F,D2 ; D2 % 32
- add.w D2,D2 ; D2 * 2
-
- ; compose RGB high color
-
- move.b (A7),D5 ; red
- swap D5
- move.w 4(A7),D5 ; green
- move.b 8(A7),D5 ; blue
- move.w D2,(bplcon3,A0)
- move.w D5,(A0,D2.W)
-
- ; compose RGB low color
-
- move.b 1(A7),D5 ; red
- swap D5
- move.w 5(A7),D5 ; green
- move.b 9(A7),D5 ; blue
- bclr #9,D3 ; lower colors
- move.w D2,(bplcon3,A0)
- move.w D5,(A0,D2.W)
-
- addq.l #1,D1
- dbf D0,.loop
- .out
- lea -12(A7),A7
- movem.l (A7)+,D2/D3/D5
- .exit
- rts
- endif
-
-
- _LoadRGB4 ;a0=viewport a1=colors d0=count
- bsr _waitvb
- lea (_custom+color),a0
- .cpy move.w (a1)+,(a0)+
- subq.w #1,d0
- bne.b .cpy
- rts
-
- _SetRGB4 ;a0=viewport d0=pen d1=red d2=green d3=blue
- ; bsr _waitvb
-
- ; compose color in D1
-
- lsl.w #4,d1
- or.w d2,d1
- lsl.w #4,d1
- or.w d3,d1
- ext.w d0
-
- ; JOTD, disabled my code
- ifeq 1
- ; update colormap if exists
-
- move.l (vp_ColorMap,A0),A0
- cmp.l #0,A0
- beq.b .skipcm
-
- move.l (cm_ColorTable,A0),A0
- add.w D0,A0
- add.w D0,A0
- move.w D1,(A0)
- .skipcm
- endif
-
- ; updates hardware registers
-
- lea (_custom+color),a1
- add.w d0,a1
- add.w d0,a1
- move.w d1,(a1)
- rts
-
- ; < A0: colormap
- ; < D0: color to get
-
- _GetRGB4:
- move.l (cm_ColorTable,A0),A1
- add.l D0,D0
- add.l D0,D0
- add.l D0,A1
- moveq.l #0,D0
- moveq.l #0,D1
- move.b (A1)+,D0
- move.b (A1)+,D1
- lsl #4,D1
- or.b D1,D0
- move.b (A1)+,D1
- lsl #8,D1
- or.b D1,D0
- rts
-
- _VBeamPos move.l (_custom+vposr),d0
- lsr.l #8,d0
- and.l #$1ff,d0
- rts
-
- _WaitTOF BSR.w _waitvb
- rts
-
- _WaitBOVP:
- bsr.w _waitvb ; -- added by JOTD
- rts ; -- I know this is not the accurate function
-
- _ReadPixel ;d0=x d1=y a1=rastport
- move.l (rp_BitMap,a1),a0
- ext.l d0
- ror.l #3,d0
- cmp.w (bm_BytesPerRow,a0),d0
- bhs .bad
- cmp.w (bm_Rows,a0),d1
- bhs .bad
- mulu (bm_BytesPerRow,a0),d1
- add.w d0,d1 ;byte offset
- rol.l #3,d0 ;bit offset
-
- movem.l d2-d4,-(a7)
- moveq #0,d2
- moveq #0,d3
- move.b (bm_Depth,a0),d4
- lea (bm_Planes,a0),a0
-
- .next move.l (a0)+,a1
- btst d0,(a1,d1.l)
- beq .1
- bset d2,d3
- .1 addq.l #1,d2
- cmp.b d2,d4
- bhi .next
-
- move.l d3,d0
- movem.l (a7)+,d2-d4
- rts
-
- .bad moveq #-1,d0
- rts
-
- ; <A1: rastport
- ; <D0: X
- ; <D1: Y
- ; >D0: 0 if OK, -1 if error
-
- _WritePixel ;d0=x d1=y a1=rastport
- move.l (rp_BitMap,a1),a0
- ext.l d0
- ror.l #3,d0
- cmp.w (bm_BytesPerRow,a0),d0
- bhs .bad
- cmp.w (bm_Rows,a0),d1
- bhs .bad
- mulu (bm_BytesPerRow,a0),d1
- add.w d0,d1 ;byte offset
- rol.l #3,d0 ;bit offset
-
- movem.l d2-d4,-(a7)
- moveq #0,d2
- move.b (rp_FgPen,a1),d3
- move.b (bm_Depth,a0),d4
- lea (bm_Planes,a0),a0
-
- .next move.l (a0)+,a1
- btst d2,d3
- beq.b .clear
- .set bset d0,(a1,d1.w)
- bra.b .1
- .clear bclr d0,(a1,d1.w)
- .1 addq.l #1,d2
- cmp.b d2,d4
- bhi.b .next
-
- move.l d3,d0
- movem.l (a7)+,d2-d4
- rts
-
- .bad moveq #-1,d0
- rts
-
- ; added by JOTD. Untested
-
- ; <A1: rastport
- ; <D0: pen
-
- _SetRast:
- movem.l D2-D7/A2-A6,-(A7)
- bsr _SetAPen
- moveq.l #0,D0 ; xmin
- moveq.l #0,D1 ; ymin
- move.l #319,D2 ; xmax
- move.l #199,D3 ; ymax
- bsr _RectFill
- movem.l (A7)+,D2-D7/A2-A6
- rts
-
- ; added by JOTD. Not optimized and not tested AT ALL, disabled
-
- ;d0=xmin d1=ymin d2=xmax d3=ymax a1=rastport
- _RectFill:
- rts
- movem.l a2/d2-d7,-(A7)
-
- move.l d0,d7 ; save D0 (xmin)
- .loopx
- .loopy
- move.w d0,d5 ; save current X
- move.w d1,d6 ; save current Y
- move.l a1,a2 ; save rastport
- bsr _WritePixel ; writes a pixel
- move.l a2,a1 ; restores rastport
- move.w d5,d0 ; restores current X
- move.w d6,d1 ; restores current Y
- addq.w #1,d0 ; next X
- cmp.w d2,d0 ; reached xmax?
- bcc.b .nexty ; out
- bra.b .loopx ; no, loop
- .nexty
- move.w d7,d0 ; reload D0 with xmin
- addq.w #1,d1 ; next Y
- cmp.w d3,d1 ; reached ymax?
- bcc.b .exit
- bra.b .loopy ; no, loop
- .exit
- movem.l (A7)+,a2/d2-d7
- rts
-
-
- **************************************************************************
- * SPRITES
- **************************************************************************
-
- _FreeSprite ;d0=pick
-
- ; frees the sprite in gfxbase
-
- bclr d0,(gb_SpriteReserved,a6)
-
- ; invalidate the sprite
-
- add.l D0,D0
- add.l D0,D0
- lea _sprites,A0
- move.l #-1,(A0,D0.W)
- rts
-
- _GetSprite ;a0=sprite d0=pick
- tst.w d0
- bmi .any
- bset d0,(gb_SpriteReserved,a6)
- bne .error
- .end move.w d0,(ss_num,a0) ; JOTD: bugfix: was a move.b
- ext.l d0
- rts
-
- .error moveq #-1,d0
- rts
-
- .any cmp.b (gb_SpriteReserved,a6),d0
- beq .error
- .next addq.w #1,d0
- bset d0,(gb_SpriteReserved,a6)
- bne .next
- bra .end
-
- _ChangeSprite ;a0=viewport a1=simplesprite a2=data
- moveq #0,d0
- move.w (ss_num,a1),d0 ; JOTD: bugfix: was a move.b
- lsl.w #2,d0
- lea (_sprites),a0
- move.l a2,(a0,d0.w)
- move.w #DMAF_SETCLR!DMAF_SPRITE,(_custom+dmacon)
- rts
-
- _MoveSprite ;a0=viewport a1=simplesprite d0=x d1=y
- ;129,41 top,left
- move.l d2,-(a7)
- moveq #0,d2
- move.w (ss_num,a1),d2 ; JOTD: bugfix: was a move.b
- lsl.w #2,d2
- lea (_sprites),a0
- move.l (a0,d2.w),a0
- add.w #129,d0 ;d0 hor
- add.w #41,d1 ;d1 top
- move.w d1,d2
- add.w (ss_height,a1),d2 ;d2 bottom
- move.b d1,(a0)+ ;top7..top0
- ror.w #1,d0
- move.b d0,(a0)+ ;hor8..hor1
- move.b d2,(a0)+ ;bot7..bot0
- lsr.w #8,d1
- lsl.w #7,d2
- addx.w d2,d2
- addx.w d1,d1
- addx.w d0,d0
- addx.w d1,d1
- move.b d1,(a0)+
- move.l (a7)+,d2
- rts
-
- **************************************************************************
- * BLITTER
- **************************************************************************
-
- _WaitBlit
- .wait
- tst.b (_ciaa)
- tst.b (_ciaa)
- btst #DMAB_BLTDONE-8,(_custom+dmaconr)
- bne.b .wait
- tst.b (_ciaa)
- rts
-
- _ClipBlit
- move.l #$FF,D7
-
- _BltBitMap ;a0=sbitmap d0=sx d1=sy
- ;a1=dbitmap d2=dx d3=dy
- ;d4=width d5=height d6=minterm d7=mask a2=buffer
-
- movem.l d2-d7/a2-a3,-(a7)
-
- lea (_custom),a3
-
- mulu (bm_BytesPerRow,a0),d1
- ext.l d0
- ror.l #4,d0
- add.w d0,d1
- add.w d0,d1 ;d1 = byte offset src
-
- mulu (bm_BytesPerRow,a1),d3
- ext.l d2
- ror.l #4,d2
- add.w d2,d3
- add.w d2,d3 ;d3 = byte offset dest
-
- lsl.w #6,d5 ;height
-
- and.w #$00f0,d6
- or.w #$070a,d6
- bsr _WaitBlit
- move.w d6,(bltcon0,a3)
-
- moveq #-1,d6
- move.w d6,(bltadat,a3)
- clr.w d2
- rol.l #4,d2 ;d2 = amount of pixels to skip in the first word in dest
- lsr.w d2,d6 ;d6.w = afwm
- swap d6
- addq.w #1,d5 ;d5 = width++ (the first word)
- sub.w #16,d4
- add.w d2,d4 ;d4 = pixels left to copy
- ext.l d4
- ror.l #4,d4
- add.w d4,d5 ;d5.w = size
- clr.w d4
- rol.l #4,d4 ;d4 = pixels left to copy (0..15)
- beq .1
- addq.w #1,d5 ;d5 = width++ (the last word)
- lsr.w d4,d6 ;d6.w = ~(alwm)
- not.w d6
- .1 move.l d6,(bltafwm,a3)
-
- clr.w d0
- rol.l #4,d0 ;pixel offset src
- sub.w d0,d2
- ; spl d4 ;d4 = 0 if first src word must be preloaded (dma-b)
- bpl .2
- ;this works only if the destination is word aligned !!!!!!
- ;(in deuteros it is...) normally a second blit is necessary in this case
- addq.w #1,d5 ;bltsize++
- subq.w #2,d3 ;dst-2
- move.w #0,(bltafwm,a3)
- add.w #16,d2
- .2 ror.w #4,d2
-
- bsr _WaitBlit ; temp
-
- move.w d2,(bltcon1,a3)
-
- move.w d5,d0
- and.w #$003f,d0
- add.w d0,d0
- move.w (bm_BytesPerRow,a0),d2
- sub.w d0,d2
- move.w d2,(bltbmod,a3)
- move.w (bm_BytesPerRow,a1),d2
- sub.w d0,d2
- move.w d2,(bltcmod,a3)
- move.w d2,(bltdmod,a3)
-
- moveq #0,d6
- .do btst d6,d7 ;mask ?
- beq .next
-
- lsl.w #2,d6
- move.l (bm_Planes,a0,d6.w),a2
- add.l d1,a2
- move.l (bm_Planes,a1,d6.w),d0
- add.l d3,d0
- bsr _WaitBlit
- movem.l d0/a2,(bltcpt,a3)
- move.l d0,(bltdpt,a3)
- move.w d5,(bltsize,a3)
- lsr.w #2,d6
-
- .next addq.w #1,d6
- cmp.b (bm_Depth,a0),d6
- beq .end
- cmp.b (bm_Depth,a1),d6
- bne .do
- .end
- movem.l (a7)+,d2-d7/a2-a3
- rts
-
- _BltTemplate ;a0=src d0=bitoffset d1=modulo
- ;a1=rp d2=x d3=y d4=width d5=height
-
- movem.l d2-d7/a2-a3,-(a7)
- lea (_custom),a3
-
- ext.l d0
- ror.l #4,d0
- add.w d0,a0
- add.w d0,a0 ;a0 = src ptr
-
- move.l (rp_BitMap,a1),a2
- mulu (bm_BytesPerRow,a2),d3
- ext.l d2
- ror.l #4,d2
- add.w d2,d3
- add.w d2,d3 ;d3 = byte offset dest
-
- lsl.w #6,d5 ;height
-
- bsr _WaitBlit
- move.w #$07aa,(bltcon0,a3)
-
- moveq #-1,d6
- move.w d6,(bltadat,a3)
- clr.w d2
- rol.l #4,d2 ;d2 = amount of pixels to skip in the first word in dest
- lsr.w d2,d6 ;d6.w = afwm
- swap d6
- addq.w #1,d5 ;d5 = width++ (the first word)
- sub.w #16,d4
- add.w d2,d4 ;d4 = pixels left to copy
- ext.l d4
- ror.l #4,d4
- add.w d4,d5 ;d5.w = size
- clr.w d4
- rol.l #4,d4 ;d4 = pixels left to copy (0..15)
- beq .1
- addq.w #1,d5 ;d5 = width++ (the last word)
- lsr.w d4,d6 ;d6.w = ~(alwm)
- not.w d6
- .1 move.l d6,(bltafwm,a3)
-
- clr.w d0
- rol.l #4,d0 ;pixel offset src
- sub.w d0,d2
- ; spl d4 ;d4 = 0 if first src word must be preloaded (dma-b)
- bpl .2
- ;this works only if the destination is word aligned !!!!!!
- ;(in deuteros it is...) normally a second blit is neccessary in this case
- addq.w #1,d5 ;bltsize++
- subq.w #2,d3 ;dst-2
- move.w #0,(bltafwm,a3)
- add.w #16,d2
- .2 ror.w #4,d2
- move.w d2,(bltcon1,a3)
-
- move.w d5,d0
- and.w #$003f,d0
- add.w d0,d0
- move.w d1,d2
- sub.w d0,d2
- move.w d2,(bltbmod,a3)
- move.w (bm_BytesPerRow,a2),d2
- sub.w d0,d2
- move.w d2,(bltcmod,a3)
- move.w d2,(bltdmod,a3)
-
- moveq #0,d6
- .do lsl.w #2,d6
- move.l (bm_Planes,a2,d6.w),d0
- add.l d3,d0
- bsr _WaitBlit
- movem.l d0/a0,(bltcpt,a3)
- move.l d0,(bltdpt,a3)
- move.w d5,(bltsize,a3)
- lsr.w #2,d6
-
- .next addq.w #1,d6
- cmp.b (bm_Depth,a2),d6
- bne .do
-
- movem.l (a7)+,d2-d7/a2-a3
- rts
-
- ; AllocBitMap, direct 3.0 ROM rip, not sure it works...
-
- _AllocBitMap:
- MOVEM.L D3/D4,-(A7)
- CMP.L #$00000100,D3
- BCC.B .LB_994E
- MOVEM.L D0/D1/A6,-(A7)
- CMPA.W #$0000,A0
- BEQ.B .LB_9900
- CMP.B $0005(A0),D2
- BNE.B .LB_9900
- CMPI.W #$805C,$0006(A0)
- BNE.B .LB_9900
- BSET #$02,D3
- .LB_9900 MOVE.L $01A4(A6),A6
- MOVEQ #$08,D0
- MOVE.W D2,D1
- BTST #$04,D3
- BNE.B .LB_9914
- MOVEQ #$28,D0
- SUBQ.W #8,D1
- BLE.B .LB_991A
- .LB_9914 ADD.W D1,D1
- ADD.W D1,D1
- ADD.W D1,D0
- .LB_991A MOVE.L #$00010000,D1
- JSRLIB AllocVec
- MOVE.L D0,A0
- TST.L D0
- MOVEM.L (A7)+,D0/D1/A6
- BEQ.B .LB_994E
- MOVE.L A0,-(A7)
- BSR.W .LB_97AA
- TST.L D0
- BNE.B .LB_9940
- MOVE.L (A7)+,D0
- MOVEM.L (A7)+,D3/D4
- RTS
- .LB_9940 MOVE.L (A7)+,A1
- MOVE.L A6,-(A7)
- MOVE.L $01A4(A6),A6
- JSR -690(A6)
- MOVE.L (A7)+,A6
- .LB_994E MOVEQ #$00,D0
- MOVEM.L (A7)+,D3/D4
- RTS
-
-
- .LB_97AA MOVEM.L D2-D4/A2/A3/A6,-(A7)
- MOVEQ #$10,D4
- BTST #$01,D3
- BEQ.B .LB_97CA
- SWAP D3
- CLR.W D3
- MOVE.B $00ED(A6),D3
- MOVE.L $01A8(A6),A1
- MOVE.B $00(A1,D3.W),D3
- ASL.B D3,D4
- SWAP D3
- .LB_97CA SUBQ.W #1,D4
- ADD.W D4,D0
- ADDQ.W #1,D4
- NEG.W D4
- AND.W D4,D0
- MOVE.W D1,$0002(A0)
- LSR.W #3,D0
- CMP.W #$0002,D2
- BLT.B .LB_97FA
- BTST #$00,$00EC(A6)
- BEQ.B .LB_97FA
- CMP.W #$0FFD,D0
- BGT.B .LB_97FA
- CMP.W #$0FFD,D1
- BGT.B .LB_97FA
- BTST #$02,D3
- BNE.B .LB_9848
- .LB_97FA MOVE.W D0,(A0)
- MULU.W D1,D0
- CLR.B $0005(A0)
- SUBQ.W #1,D2
- MOVE.L $01A4(A6),A6
- MOVE.L D0,D4
- MOVEQ #$02,D1
- BTST #$00,D3
- BEQ.B .LB_9818
- OR.L #$00010000,D1
- .LB_9818 MOVE.L D1,D3
- LEA $0008(A0),A2
- MOVE.L A0,A3
- .LB_9820 MOVE.L D4,D0
- MOVE.L D3,D1
- JSR -198(A6)
- MOVE.L D0,(A2)+
- BEQ.B .LB_983C
- ADDQ.B #1,$0005(A3)
- DBF D2,.LB_9820
- MOVEM.L (A7)+,D2-D4/A2/A3/A6
- MOVEQ #$00,D0
- RTS
- .LB_983C MOVE.L A3,A0
- MOVEM.L (A7)+,D2-D4/A2/A3/A6
- BSR.B .LB_98A2
- MOVEQ #-$01,D0
- RTS
- .LB_9848 MOVEM.L D0/D1/A6,-(A7)
- MOVE.L D0,D4
- MOVE.L A0,A3
- MOVE.B D2,$0005(A0)
- MULU.W D2,D0
- MOVE.W D0,(A0)
- MULU.W $0002(A0),D0
- MOVEQ #$02,D1
- BTST #$00,D3
- BEQ.B .LB_986A
- OR.L #$00010000,D1
- .LB_986A MOVE.L $01A4(A6),A6
- JSR -198(A6)
- TST.L D0
- BNE.B .LB_9880
- MOVEM.L (A7)+,D0/D1/A6
- MOVE.L A3,A0
- BRA.W .LB_97FA
- .LB_9880 SUBQ.W #1,D2
- LEA $0008(A3),A2
- EXT.L D4
- .LB_9888 MOVE.L D0,(A2)+
- ADD.L D4,D0
- DBF D2,.LB_9888
- MOVE.W #$805C,$0006(A3)
- LEA $000C(A7),A7
- MOVEM.L (A7)+,D2-D4/A2/A3/A6
- MOVEQ #$00,D0
- RTS
- .LB_98A2 MOVEM.L D2/D3/A2/A6,-(A7)
- MOVEQ #$00,D2
- MOVE.B $0005(A0),D2
- CMPI.W #$805C,$0006(A0)
- BNE.B .LB_98B6
- MOVEQ #$01,D2
- .LB_98B6 MOVE.L $01A4(A6),A6
- MOVE.W (A0),D3
- MULU.W $0002(A0),D3
- LEA $0008(A0),A2
- BRA.B .LB_98CE
- .LB_98C6 MOVE.L (A2)+,A1
- MOVE.L D3,D0
- JSR -210(A6)
- .LB_98CE DBF D2,.LB_98C6
- MOVEM.L (A7)+,D2/D3/A2/A6
- RTS
-
-
- abm_table:
- DC.B $00,$01,$01,$02,$00,$E0,$00,$00
- DC.B $01,$00,$02,$00,$01,$06,$0C,$00
- DC.B $01,$80,$01,$FE,$0C,$00,$01,$FC
- DC.B $00,$00,$00,$8E,$01,$81,$00,$90
- DC.B $02,$81,$01,$E4,$00,$00,$00,$92
- DC.B $00,$18,$00,$94,$00,$20,$01,$04
- DC.B $00,$24,$01,$FE,$0C,$00,$01,$FE
- DC.B $00,$00,$01,$FE,$00,$00,$01,$FE
- DC.B $00,$00,$01,$FE,$00,$00,$01,$FE
- DC.B $00,$00,$01,$FE,$00,$00,$01,$FE
- DC.B $00,$00,$0C,$01,$FF,$FE,$0C,$01
- DC.B $FF,$FE,$00,$8A,$00,$00,$01,$06
- DC.B $0C,$00,$FF,$FF,$FF,$FE,$63,$69
- DC.B $61,$62,$2E,$72,$65,$73,$6F,$75
- DC.B $72,$63,$65,$00,$00,$00,$00,$00
- DC.B $FF,$F8,$FF,$F0,$FF,$F0,$FF,$E0
- DC.B $FF,$F8,$FF,$F8,$FF,$F8,$FF,$F0
- DC.B $FF,$F8,$FF,$F8,$FF,$F8,$FF,$F8
- DC.B $FF,$F8,$FF,$F0,$FF,$F0,$FF,$E0
- DC.B $FF,$F8,$FF,$F8,$FF,$F8,$FF,$F0
- DC.B $FF,$F8,$FF,$F8,$FF,$F8,$FF,$F8
- DC.B $FF,$F8,$FF,$F0,$FF,$F0,$FF,$E0
- DC.B $FF,$FC,$FF,$F8,$FF,$F8,$FF,$F0
- DC.B $FF,$FE,$FF,$FC,$FF,$FC,$FF,$F8
- DC.B $00,$08,$00,$08,$00,$08,$00,$08
- DC.B $00,$04,$00,$08,$00,$08,$00,$08
- DC.B $00,$02,$00,$04,$00,$04,$00,$08
- DC.B $64,$65,$66,$61,$75,$6C,$74,$2E
- DC.B $6D,$6F,$6E,$69,$74,$6F,$72,$00
- DC.B $64,$65,$66,$61,$75,$6C,$74,$2E
- DC.B $6D,$6F,$6E,$69,$74,$6F,$72,$00
- DC.B $6E,$74,$73,$63,$2E,$6D,$6F,$6E
- DC.B $69,$74,$6F,$72,$00,$00,$70,$61
- DC.B $6C,$2E,$6D,$6F,$6E,$69,$74,$6F
- DC.B $72,$00,$00,$00,$80,$00,$00,$0F
- DC.B $00,$00,$00,$00,$80,$00,$00,$20
-
- ;<a0 src bitmap-struct
- ;<a1 dest rastport-struct
- ;<a2 mask bitmap, size as the one in a0
- ;<d0 x src bitmap
- ;<d1 y src bitmap
- ;<d2 x dest rastport
- ;<d3 y dest rastport
- ;<d4 width
- ;<d5 height
- ;<d6 minterm
-
- ;internal:
- ;channel a-mask
- ;channel b-src data
- ;channel c-dest data as src
- ;a3 byteoffset&fffe for start in src/mask bitplane
- ;a4 byteoffset&fffe for start in dest bitplane
- ;a6 value for dest bitmap-struct (from rastport); later $dff000
- ;minterm is ignored, i dont know why it doesnt work right with it, i use
- ; $CA instead which works (at least for Traders)
- ;d6/d7 scratch
- ;
- ; by Harry
- ;
- _BLTMASKBITMAPRASTPORT
- movem.l a1-a6/d7,-(A7)
- movem.l d0-d6,-(A7)
-
- ;some tests for the 3 cases
- move.l d0,d6
- and.w #$f,d6
- move.l d2,d7
- and.w #$f,d7
- cmp.l d6,d7
- blo.s .w1
-
- add.l d4,d6
- add.l d4,d7
- subq.l #1,d6
- subq.l #1,d7
- and.l #$fffffff0,d6
- and.l #$fffffff0,d7
- cmp.l d6,d7
- bls.w .bl1_1
-
- .w2 ;case: wrap, amount of words of blitwindow of src < that of dest
- ;task: blit by 2 steps: all but the last strip, then the last strip
- move.l d2,d7
- add.l d4,d7
- and.l #$f,d7
- sub.l d7,d4
- move.l 6*4(A7),d6
- bsr.s .bl1
- add.l d4,d0
- add.l d4,d2
- move.l d7,d4
- bra.s .bl2_2
-
-
- .w1 ;case: wrap, amount of words of blitwindow of src and of dest equal
- ; and (x dest rastport)%16 < (x src bitmap)%16)
- ;task: blit by 2 steps: all but the last strip, then the last strip
- ;d6 already (x src)%16
- move.l d6,d7
- add.l d4,d7
- cmp.l #$10,d7
- blo.s .w1_last
- and.l #$fffffff0,d7
- sub.l d6,d7
- move.l d7,d4
- move.l 6*4(A7),d6
- bsr.s .bl2
- move.l 4*4(A7),d4
- sub.l d7,d4
- beq.w .end
- add.l d7,d0
- add.l d7,d2
- .w1_last
- bra.s .bl2_2
-
- .bl2
- movem.l a1-a6/d7,-(A7)
- movem.l d0-d6,-(A7)
-
- .bl2_2 sub.l a3,a3
- lea.l (-2).w,a4
-
- ;computing bltawm
- move.l d0,d6
- and.l #$f,d6
- moveq.l #-1,d7
- lsr.l d6,d7 ;value for bltafwm in highword
- move.l d4,d6
- add.l d0,d6
- neg.l d6
- and.l #$f,d6 ;for bltalwm only the bits which dont fit
- ;in the last word are interesting
- lsl.w d6,d7 ;value for bltalwm in lowword
- move.l d7,-(A7) ;value for bltawm
- and.w d7,(A7) ;special case: bltafwm is mask for all
- clr.w 2(A7) ; bltalwm is 0 for masking it out
- add.l #$10,d4 ;1 word longer blit for taking bltalwm in effect
- bra.s .all
-
- .w3 ;no wrap
- .bl1 movem.l a1-a6/d7,-(A7)
- movem.l d0-d6,-(A7)
-
- .bl1_1 ;case: no wrap, amount of words of blitwindow of src and of dest equal
- sub.l a3,a3
- sub.l a4,a4
-
- ;computing bltawm
- move.l d0,d6
- and.l #$f,d6
- moveq.l #-1,d7
- lsr.l d6,d7 ;value for bltafwm in highword
- move.l d4,d6
- add.l d0,d6
- neg.l d6
- and.l #$f,d6 ;for bltalwm only the bits which dont fit
- ;in the last word are interesting
- lsl.w d6,d7 ;value for bltalwm in lowword
- move.l d7,-(A7) ;value for bltawm
-
- .all ;computing shift
- move.w d0,d6
- move.w d2,d7
- and.l #$f,d6
- and.l #$f,d7
- sub.w d6,d7
- and.w #$f,d7 ;if destination would have neg. shift,
- swap D7
- lsr.l #4,d7
- move.l d7,a5 ;shift in a5, already as BLTCONx
-
- ;computing offset in src/mask bitplane
- moveq.l #0,d7
- move.w bm_BytesPerRow(A0),d7
- mulu.w d1,d7 ;bytes in bitplane until start of wanted line
- add.l d7,a3
- move.l d0,d7
- lsr.l #3,d7 ;whole bytes in bpl from start of line until column
- and.w #$fffe,d7
- add.l d7,a3 ;offset from src bpl until start of blitter
-
- ;computing offset in dest bitplane, a4 already set
- move.l rp_BitMap(A1),a6
- moveq.l #0,d7
- move.w bm_BytesPerRow(A6),d7
- mulu.w d3,d7 ;bytes in bpl until start of wanted line
- add.l d7,a4
- move.l d2,d7
- lsr.l #3,d7 ;whole bytes in bpl from start of line until column
- and.w #$fffe,d7
- add.l d7,a4 ;offset from dest bpl until start of blitter
-
- .1 ;computing height in lines in BLITSIZE-format
- lsl.l #6,d5
- ;computing width in bytes
- move.l d0,d7
- and.l #$f,d7
- add.l d4,d7
- add.l #$f,d7
- lsr.l #4,d7
- move.l d7,d6
- and.l #$3f,d6
- or.w d6,d5 ;BLITSIZE
-
- ;computing modulo for src/mask bpl,
- ; d7 contains already blitwidth in words
- add.l d7,d7
- moveq.l #0,d1 ;not needed anymore
- move.w bm_BytesPerRow(A0),d1
- and.w #$fffe,d1
- sub.w d7,d1 ;modulo for src/mask bpl
-
- ;computing modulo for dest bpl
- ; d7 contains already blitwidth in bytes
- moveq.l #0,d3 ;not needed anymore
- move.w bm_BytesPerRow(A6),d3
- and.w #$fffe,d3
- sub.w d7,d3 ;modulo for dest bpl
-
- ;evaluate bltbon0
- move.l (A7)+,d7
- move.l a5,d6
- ; or.w 6*4+2(A7),d6 ;d6 from stack again (SKIPPED)
- or.w #$FCA,d6 ;all channels and minterms
-
-
- ;get # of planes to blit, take minimum of src and dest
- moveq.l #0,d4 ;count of planes of src for loop
- move.b bm_Depth(A6),d4 ;take lower amount of planes for safety
- cmp.b bm_Depth(A0),d4
- blo.s .4
- move.b bm_Depth(A0),d4
- .4
-
- ;set registers which dont change while the whole blit
- lea.l $dff000,a6
- bsr.w _WaitBlit
- move.l d7,$44(A6) ;bltawm
- move.w d1,$62(A6) ;bltbmod
- move.w d1,$64(A6) ;bltamod
- move.w d3,$60(A6) ;bltcmod
- move.w d3,$66(A6) ;bltdmod
- move.w d6,$40(A6) ;bltcon0
- move.w a5,$42(A6) ;bltcon1
-
- ;init loop-counter
- moveq.l #0,d7
- move.b rp_Mask(A1),d7 ;which planes are to change?
- moveq.l #0,d6 ;counter for planes
-
- ;here the loop for blitting each plane starts
- .2 lsr.b #1,d7
- beq.s .3 ;skip if bitplane not to change
-
- bsr.w _WaitBlit
-
- ;compute startaddress for src
- move.l d6,d1
- lsl.w #2,d1
- move.l bm_Planes(A0,d1.w),a5
- add.l a3,a5
- move.l a5,$4c(A6)
-
- ;compute startaddress for mask
- lea.l (a2,a3.l),a5
- move.l a5,$50(A6)
-
- ;compute startaddress for dest
- move.l rp_BitMap(A1),a5
- move.l bm_Planes(A5,d1.w),a5
- add.l a4,a5
- move.l a5,$48(A6)
- move.l a5,$54(A6)
-
- ;start blit
- move.w d5,$58(A6)
-
- .3 addq.w #1,d6
- cmp.b d4,d6
- bne.s .2
- ; bsr.w _WaitBlit
- .end movem.l (A7)+,d0-d6
- movem.l (A7)+,a1-a6/d7
-
- rts
-
- ; Draw
- ; < A1: rastport
- ; < D0: new x
- ; < D1: new y
-
- _Draw:
- ; draw the line still to do
-
- ; update rastport coordinates
-
- move.w D0,(rp_cp_x,A1)
- move.w D1,(rp_cp_y,A1)
-
- rts
-
- ; < A0: cprlist structure
-
- _FreeCprList:
- move.l A6,-(A7)
- cmp.l #0,A0
- beq.b .end
- moveq.l #0,D0
- move.w (crl_MaxCount,A0),D0
- add.l D0,D0
- add.l D0,D0
- beq.b .end
- move.l (gb_ExecBase,A6),A6
- move.l (crl_start,A0),A1
- cmp.l #0,A1
- beq.b .end
- JSRLIB FreeMem
- .end
- move.l (A7)+,A6
- RTS
-